package com.qf.flash.ui.home.adapter;

import android.text.TextUtils;
import android.widget.TextView;

import com.qf.flash.R;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;

/**
 * 2020/3/4 17:11
 */
public class NumberItem extends BaseRViewItem<String> {
    private String unit = "人";

    public void setUnit(String unit) {
        this.unit = unit;
    }

    @Override
    public int getItemLayout() {
        return R.layout.item_type_number;
    }

    @Override
    public void convert(RViewHolder holder, String entity, int position, int itemSize) {
        int singleChosenPosition = holder.getAdapter().getSingleChosenPosition();
        TextView view = holder.getView(R.id.tv_content);
        if (!TextUtils.equals("全部", entity))
            view.setText(entity + unit);
        else
            view.setText(entity);
        if (position == singleChosenPosition) {
            view.setBackgroundResource(R.drawable.shape_comm_orange);
            view.setTextColor(view.getContext().getResources().getColor(R.color.color_333333));
        } else {
            view.setBackground(null);
            view.setTextColor(view.getContext().getResources().getColor(R.color.color_666666));
        }
    }
}
